FROM node:18-alpine as build-stage

WORKDIR /app

COPY . .

RUN npm install --registry=https://registry.npmmirror.com
RUN npm run build

#生产stage
FROM node:18-alpine as production-stage
COPY --from=build-stage /app/dist /app
COPY --from=build-stage /app/src/views /app/views
COPY --from=build-stage /app/package.json /app
COPY --from=build-stage /app/.sequelizerc /app/.sequelizerc
COPY --from=build-stage /app/migrate /app/migrate
# COPY --from=build-stage /app/yarn.lock /app/yarn.lock

WORKDIR /app

RUN npm install --production --registry=https://registry.npmmirror.com
ENV TZ Asia/Shanghai
ENV NODE_ENV production

EXPOSE 3000

CMD ["node", "main.js"]
